package ace.cmp.spring.data.jdbc.test.dao.mapper;

import ace.cmp.spring.data.jdbc.test.dao.entity.CASUser;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author caspar
 * @date 2023/2/15 13:42
 */
@Mapper
public interface CASUserMapper {
  int FIND_ALL_BY_MOBILE_LIKE_LIMIT = 3;

  @Select(
      "SELECT * FROM cas_user WHERE mobile LIKE CONCAT('%', #{mobile}, '%') LIMIT "
          + FIND_ALL_BY_MOBILE_LIKE_LIMIT)
  List<CASUser> findAllByMobileLike(@Param("mobile") String mobile);

  @Select("SELECT * FROM cas_user WHERE id = #{id}")
  CASUser findById(@Param("id") String id);
}
